{include file="public/layout" /}
{include file="gzh/header" /}

<body class="bodystyle" style="overflow-y: scroll; cursor: default; -moz-user-select: inherit;">
<div id="append_parent"></div>
<div id="ajaxwaitid"></div>
{include file="canal/left" /}
<div class="page min-hg-c-10" style="min-width:auto;margin-left:100px;">
    {include file="gzh/material_bar" /}

    <div class="flexigrid">
        <div class="mDiv pt0">
            <div class="ftitle">
                <div class="fbutton">
                  <a href="{:url('Gzh/material_text_add')}">
                      <div class="add" title="新增素材">
                          <span><i class="layui-icon layui-icon-addition"></i>新增文字素材</span>
                      </div>
                  </a>
                </div>
            </div>
            <form class="navbar-form form-inline" action="" method="get" onsubmit="layer_loading('正在处理');">
                {$searchform.hidden|default=''}
                <div class="sDiv">
                    <div class="sDiv2">
                        <input type="hidden" name="token" value="{$Request.param.token}">
                        <input type="text" size="30" name="keywords" value="{$Request.param.keywords}" class="qsbox" placeholder="标题搜索...">
                        <input type="submit" class="btn" value="搜索">
                        <i class="iconfont e-sousuo"></i>
                    </div>
                </div>
            </form>
        </div>
        <div class="hDiv">
            <div class="hDivBox">
                <table cellspacing="0" cellpadding="0" style="width: 100%">
                    <thead>
                        <tr>
                            <th class="sign w40" axis="col0">
                                <div class="tc"><input type="checkbox" autocomplete="off" class="checkAll"></div>
                            </th>
                            <th abbr="article_title" axis="col3" class="">
                                <div class="text-l10">内容</div>
                            </th>
                            <th abbr="article_time" axis="col6" class="w160">
                                <div class="tc">更新时间</div>
                            </th>
                            <th axis="col1" class="w150">
                                <div class="tc">操作</div>
                            </th>
                        </tr>
                    </thead>
                </table>
            </div>
        </div>
        <div class="bDiv" style="height: auto;">
            <div id="flexigrid" cellpadding="0" cellspacing="0" border="0">
                <table style="width: 100%">
                    <tbody>
                    {volist name="$list" id="vo"}
                        <tr class="trSelected">
                            <td class="sign">
                                <div class="w40 tc"> <input type="checkbox" autocomplete="off" name="ids[]" value="{$vo.id}"> </div>
                            </td>
                            <td class="" style="width: 100%;">
                                <div class="text-l10">{$vo.intro}</div>
                            </td>
                            <td class="">
                                <div class="w160 tc"> {$vo.add_time|date='Y-m-d H:i:s',###} </div>
                            </td>
                            <td class="operation">
                                <div class="w150 tc">
                                    <a href="{:url('Gzh/material_text_edit',['id'=>$vo.id])}" class="btn blue">编辑</a>
                                    <i></i>
                                    <a href="javascript:void(0);" data-url="{:url('Gzh/material_del')}" data-id="{$vo.id}" onclick="delfun(this);" class="btn blue">删除</a>
                                </div>
                            </td>
                        </tr>
                    {/volist}
                    </tbody>
                </table>
            </div>
            <div class="iDiv" style="display: none;"></div>
        </div>
        <div class="tDiv">
            <div class="tDiv2">
                <div class="fbutton checkboxall">
                    <input type="checkbox" class="checkAll">
                </div>
                <div class="fbutton">
                    <a onclick="batch_del(this, 'ids');" data-url="{:url('Gzh/material_del')}" class="layui-btn layui-btn-primary">批量删除</a>
                </div>
                {$pageStr}
            </div>
            <div style="clear:both"></div>
        </div>
        <!--分页位置-->
        {$pageStr}
    </div>
</div>
<script type="text/javascript">
    $(document).ready(function(){
        // 表格行点击选中切换
        $('#flexigrid > table>tbody >tr').click(function(){
            $(this).toggleClass('trSelected');
        });

        // 点击刷新数据
        $('.fa-refresh').click(function(){
            location.href = location.href;
        });
    });

    // 删除
    function delfun(obj){
        layer.confirm('确认彻底删除？', {
            // shade: layer_shade,
            area: ['480px', '190px'],
            move: false,
            title: '提示',
            btnAlign:'r',
            closeBtn: 3,
            btn: ['确定', '取消'] ,//按钮
            success: function () {
                $(".layui-layer-content").css('text-align', 'left');
            }
        }, function(){
            layer_loading('正在处理');
            // 确定
            $.ajax({
                type : 'post',
                url : $(obj).attr('data-url'),
                data : {del_id:$(obj).attr('data-id'), _ajax:1},
                dataType : 'json',
                success : function(data){
                    layer.closeAll();
                    if(data.code == 1){
                        layer.msg(data.msg, {icon: 6});
                        window.location.reload();
                    }else{
                        layer.alert(data.msg, {icon: 5, title:false});
                    }
                }
            })
        }, function(index){
            layer.close(index);
        });
        return false;
    }

    //批量删除提交
    function batch_del(obj, name) {
        var a = [];
        $('input[name^='+name+']').each(function(i,o){
            if($(o).is(':checked')){
                a.push($(o).val());
            }
        })
        if(a.length == 0){
            layer.alert('请至少选择一项', {
                // shade: layer_shade,
                area: ['480px', '190px'],
                move: false,
                title: '提示',
                btnAlign:'r',
                closeBtn: 3,
                success: function () {
                    $(".layui-layer-content").css('text-align', 'left');
                }
            });
            return;
        }

        // 删除按钮
        layer.confirm('确认批量彻底删除？', {
            // shade: layer_shade,
            area: ['480px', '190px'],
            move: false,
            title: '提示',
            btnAlign:'r',
            closeBtn: 3,
            btn: ['确定', '取消'] ,//按钮
            success: function () {
                $(".layui-layer-content").css('text-align', 'left');
            }
        }, function () {
            layer_loading('正在处理');
            $.ajax({
                type: "POST",
                url: $(obj).attr('data-url'),
                data: {del_id:a, _ajax:1},
                dataType: 'json',
                success: function (data) {
                    layer.closeAll();
                    if(data.code == 1){
                        layer.msg(data.msg, {icon: 6});
                        window.location.reload();
                    }else{
                        layer.alert(data.msg, {icon: 5, title:false});
                    }
                },
                error:function(e){
                    layer.closeAll();
                    layer.alert(e.responseText, {icon: 5, title:false});
                }
            });
        }, function (index) {
            layer.closeAll(index);
        });
    }

</script>

{include file="public/footer" /}